{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b3108e3d-dc5b-4f4f-8bd5-88c71e422b38",
   "metadata": {},
   "source": [
    "# Parallel Coordinates Plot\n",
    "\n",
    "A parallel coordinates plot of 4 features of the penguins dataset to analyze how they are related with the species. We can see, for instance, that Gentoo penguins dominate the `flipper_length_mm` feature, having the highest flipper lengths."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eb7fa534-d6ef-4465-a215-4ea13b5b20f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot\n",
    "import pandas as pd\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "\n",
    "df = hvplot.sampledata.penguins(\"pandas\")\n",
    "df_scaled = df\n",
    "cols = [\"bill_length_mm\", \"bill_depth_mm\", \"flipper_length_mm\", \"body_mass_g\"]\n",
    "scaler = MinMaxScaler()\n",
    "scaled_features = scaler.fit_transform(df[cols])\n",
    "df_scaled = pd.DataFrame(scaled_features, columns=cols)\n",
    "df_scaled[\"species\"] = df[\"species\"]\n",
    "\n",
    "hvplot.plotting.parallel_coordinates(\n",
    "    df_scaled,\n",
    "    class_column=\"species\",\n",
    "    title=\"Parallel Coordinates Plot (Bokeh)\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56106dc0-9a95-48b0-94f9-f10d3d4a2c7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot\n",
    "import pandas as pd\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "hvplot.extension(\"matplotlib\")\n",
    "\n",
    "df = hvplot.sampledata.penguins(\"pandas\")\n",
    "df_scaled = df\n",
    "cols = [\"bill_length_mm\", \"bill_depth_mm\", \"flipper_length_mm\", \"body_mass_g\"]\n",
    "scaler = MinMaxScaler()\n",
    "scaled_features = scaler.fit_transform(df[cols])\n",
    "df_scaled = pd.DataFrame(scaled_features, columns=cols)\n",
    "df_scaled[\"species\"] = df[\"species\"]\n",
    "\n",
    "hvplot.plotting.parallel_coordinates(\n",
    "    df_scaled,\n",
    "    class_column=\"species\",\n",
    "    title=\"Parallel Coordinates Plot (Matplotlib)\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22add9a1-1460-4cca-bfdb-7082d17112a3",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Parallel Coordinates reference documentation](../../ref/api/manual/hvplot.plotting.parallel_coordinates.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
